<!--超期管理-->
<template>
  <div class="app-container">
    <div class="filter-container">
      <div class="car-label">关键字:</div>
      <el-input v-model="listQuery.title" placeholder="Title" style="width:130px;" class="filter-item" />
      <div class="car-label">关联银行:</div>
      <el-select v-model="listQuery.type" placeholder="Type" clearable class="filter-item" style="width: 130px">
        <el-option v-for="item in calendarTypeOptions" :key="item.key" :label="item.display_name+'('+item.key+')'" :value="item.key" />
      </el-select>
      <el-button v-waves style="margin-left: 10px" class="filter-item" type="primary" icon="el-icon-search">
        搜索
      </el-button>
    </div>
    <ve-table
      style="width:100%"
      :columns="columns"
      :table-data="tableData"
      :border-x="true"
      row-key-field-name="id"
      :border-y="true"
      :row-style-option="rowStyleOption"
      :checkbox-option="checkboxOptipon"
    />
    <div class="table-pagination">
      <ve-pagination
        :total="totalCount"
        :page-index="pageIndex"
        :page-size="pageSize"
        @on-page-number-change="pageNumberChange"
        @on-page-size-change="pageSizeChange"
      />
    </div>
  </div>
</template>

<style lang="scss" scoped>
  .table-pagination {
    margin-top: 20px;
    text-align: right;
  }
  .right-btn{
    float: right;
  }
</style>

<script>

export default {
  data() {
    return {
      // page index
      pageIndex: 1,
      dataTable: [],
      totalCount: '',
      // page size
      pageSize: 10,
      listQuery: {},
      rowStyleOption: { // 表格样式
        stripe: true, // 斑马纹
        hoverHighlight: true, // hover高亮
        clickHighlight: true // 点击行高亮
      },
      checkboxOptipon: {
        // 行选择改变事件
        selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
          console.log(row, isSelected, selectedRowKeys)
        },
        // 全选改变事件
        selectedAllChange: ({ isSelected, selectedRowKeys }) => {
          console.log(isSelected, selectedRowKeys)
        }
      },
      columns: [
        {
          field: '',
          key: 'f',
          // type=checkbox
          type: 'checkbox',
          title: '',
          width: 50,
          align: 'center'
        },
        {
          field: '',
          key: 'a',
          title: '序号',
          align: 'center',
          renderBodyCell: ({ row, column, rowIndex }, h) => {
            return (this.pageIndex - 1) * this.pageSize + rowIndex + 1
          }
        },
        { field: 'name', key: 'b', title: '订单编号', align: 'center', width: '100px' },
        { field: 'date', key: 'c', title: '客户姓名', align: 'left', width: '130px' },
        { field: 'address', key: 'e', title: '贷款金额', width: '130px' },
        { field: 'address', key: 'f', title: '部门', width: '100px' },
        { field: 'address', key: 'g', title: '业务员', width: '100px' },
        { field: 'address', key: 'h', title: '贷款银行', width: '100px' },
        { field: 'hobby', key: 'i', title: '合同用时', align: 'left', width: '130px' },
        { field: 'hobby', key: 'g', title: '合同实效', align: 'left', width: '130px' },
        { field: 'hobby', key: 'k', title: '合同超期', align: 'left', width: '130px' },
        { field: 'hobby', key: 'l', title: '车资用时', align: 'left', width: '130px' },
        { field: 'hobby', key: 'm', title: '车资时效', align: 'left', width: '130px' },
        { field: 'hobby', key: 'n', title: '车资超期', align: 'left', width: '130px' },
        { field: 'hobby', key: 'o', title: '抵押用时', align: 'left', width: '130px' },
        { field: 'hobby', key: 'p', title: '抵押时效', align: 'left', width: '130px' },
        { field: 'hobby', key: 'q', title: '抵押超期', align: 'left', width: '130px' }
      ]
    }
  },
  computed: {
  },
  created() {
    this.initDatabase()
  },
  methods: {
    // page number change
    pageNumberChange(pageIndex) {
      this.pageIndex = pageIndex
    },

    // page size change
    pageSizeChange(pageSize) {
      this.pageIndex = 1
      this.pageSize = pageSize
    },

    // Simulation table data
    async initDatabase() {
      this.tableData = [];
      let param = {appId:"9999",pageIndex:this.pageIndex,pageSize:this.pageSize};
      let data = await this.$http.get('/auth/distributor/get', param)
      console.log(data);
      if (data.code === 200) {
        this.tableData = data.data;
        this.totalCount = data.data.length;
      } else {

      }


      console.log(this.tableData)




    },
    async addData(){
      this.formData.appId = "9999";
      let data = await this.$http.post('/auth/distributor/insert', this.formData)
      console.log(data);
      if (data.code === 200) {
        this.newDialog = false;
        this.initDatabase();
      } else {

      }
    }
  }
}
</script>
